import torch.nn as nn
import torch.nn.functional as F
import torch



'''
input1 = torch.randn(5, 128)
input2 = torch.randn(5, 128)
cos = nn.CosineSimilarity(dim=1, eps=1e-6)
output = cos(input1, input2)
print(output)

n, d, m = 3, 20, 7
embedding = nn.Embedding(n, d, max_norm=1.0)
idx = torch.tensor([1])
b = embedding(idx) 
print(b)
  
m = nn.Dropout(p=0.2)
input = torch.ones(5, 5)
print(input)
output = m(input)
print(output)

transformer_model = nn.Transformer(nhead=16, num_encoder_layers=12)
src = torch.rand((10, 32, 512))
tgt = torch.rand((20, 32, 512))
out = transformer_model(src, tgt)
print(out)

# NLP Example
batch, sentence_length, embedding_dim = 20, 5, 10
embedding = torch.randn(batch, sentence_length, embedding_dim)
layer_norm = nn.LayerNorm(embedding_dim)
# Activate module
output=layer_norm(embedding)
print(output)

# Without Learnable Parameters
m = nn.BatchNorm1d(5, affine=True)
input = torch.ones(1,5, 2)
output = m(input)

print(output)



m = nn.Softmin(dim=1)
input = torch.ones(2, 3)
output = m(input)

print(output)

m = nn.ELU()
input = torch.randn(2)
output = m(input)
print(output)



m = nn.ConstantPad1d(2, 3.5)
input = torch.randn(1, 2, 4)
input
output=m(input)
print(output)
 

m = nn.ZeroPad1d(2)
input = torch.randn(1, 2, 4)
output=m(input) 

print(output)


m = nn.ReflectionPad2d(2)
input = torch.arange(9, dtype=torch.float).reshape(1, 1, 3, 3)
input
output=m(input)

print(output)

m = nn.ReflectionPad1d(2)
input = torch.ones(5,5)

output=m(input)
print(output)
 

# target output size of 5
m = nn.AdaptiveMaxPool1d(2)
input = torch.randn(1, 1, 8)
output = m(input)
print(output)

class Model(nn.Module):
    def __init__(self) -> None:
        super().__init__()
        #self.line=nn.Linear(5,3)
        #self.sequential = nn.Sequential(
        #           nn.Linear(5,3),nn.Linear(3,8),nn.Linear(8,2)
        #       )
        
        #self.linears = nn.ModuleList([nn.Linear(5, 5) for i in range(10)])

        #self.conv1d= nn.Conv1d(16, 5, 3, stride=3)

        #self.conv2d = nn.Conv2d(5, 1, 3,stride=3)

        #self.conv3d = nn.Conv3d(2, 1, 3, stride=3)
        #self.maxPool1d= nn.MaxPool1d(3, stride=3)
        #self.maxPool2d=nn.MaxPool2d(3, stride=(3,1,))

        #self.conv1 = nn.Conv2d(1, 20, 5)
        #self.conv2 = nn.Conv2d(20, 20, 5)

    def forward(self, x):
        #x=self.line(x)
        
        #for i, l in enumerate(self.linears):
        #    x = self.linears[i // 2](x) + l(x)

        #x=self.conv1d(x)

        #x=self.conv2d(x)
   
        #x=self.conv3d(x)
        #x=self.maxPool1d(x)

        #x=self.maxPool2d(x)


        return x
    
m=Model()


#input = torch.ones(1, 5, 6, 6)


#input = torch.ones(1, 2, 6, 6,6)


#input = torch.range(0.0, 5.0).reshape(1,6)

input = torch.randn(1, 1, 6, 6)

output=m(input)  

#print(output)
'''

 